package com.g2room.model;

import com.g2room.file.excel.ExcelField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class User {
    private int id;
    @ExcelField(name = "名称")
    private String name;
    @ExcelField(name = "年龄")
    private Integer age;
    @ExcelField(name = "性别")
    private String sex;

    public static List<User> generateUsers(int i) {
        List<User> users = new ArrayList<>();
        IntStream.range(0, i).forEach(n -> {
            Random random = new Random();
            users.add(generateUser(n));
        });
        return users;
    }

    public static User generateUser(int id) {
        Random random = new Random();
        return User.builder().age(10 * random.nextInt(10)).id(id).name("name_" + id).sex(random.nextInt() % 2 == 0 ? "男" : "女").build();
    }
}
